package com.cyf.selfhelppay;

import com.cyf.selfhelppay.network.bean.SHPayGetParkingInfoReq;
import com.cyf.selfhelppay.network.bean.SHPayGetParkingInfoResp;
import com.cyf.selfhelppay.network.bean.SHPayGetQrcodeReq;
import com.cyf.selfhelppay.network.bean.SHPayGetQrcodeRsp;
import com.cyf.selfhelppay.service.SHPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Controller
@RestController
@Api("自助缴费机相关api")
@RequestMapping("shpay")
public class SHPayHttpController {

    private static final Logger logger = LoggerFactory.getLogger(SHPayHttpController.class);

    @Autowired
    private SHPayService shPayService;

    @ApiOperation(value="获取入场信息及车牌号")
    @PostMapping(value="/getCarInInfo")
    public SHPayGetParkingInfoResp getCarInInfo(@RequestBody SHPayGetParkingInfoReq req){
        return shPayService.getCarInInfo(req);
    }

    @ApiOperation(value = "获取优惠券")
    @PostMapping(value = "/getQrcode")
    public SHPayGetQrcodeRsp getCoupon(@RequestBody SHPayGetQrcodeReq req,
                                       HttpServletRequest request) {
        req.setReqIp(request.getRemoteHost());
        return shPayService.getQrcode(req);
    }
}
